#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

class A
{
public:

  A() :m_iVal(0) { test(); }

  virtual void func() { std::cout << m_iVal << std::endl; }

  void test() { func(); }
public:

  int m_iVal;
};



class B : public A
{
public:

	B() { test(); }

	virtual void func()

	{
		++m_iVal;
		std::cout << m_iVal << std::endl;
	}

};



int main(int argc, char* argv[])
{

	A* p = new B;

	p->test();

	return 0;

}

